/*
 * BlackLightning.PluginLib.LoginClients.ILoginClient
 * Andy Tidball
 * 
 * Project: Black Lightning Plugin Library
 * Copyright: GNU General Public License
 */

using System;
using BlackLightning.PluginLib;

namespace BlackLightning.PluginLib.LoginClients {
	/// <summary>
	/// Defines the interface between Black Lightning and login clients.
	/// </summary>
	public interface ILoginClient : IMessageHandler {
		/// <summary>
		/// Called by Black Lightning to retrieve the value of a Property of the ILoginClient.
		/// </summary>
		/// <param name="Property">The property to retrieve the value for.</param>
		/// <returns>The value of the requested property.</returns>
		object GetProperty(LoginClientProperty Property);

		/// <summary>
		/// Provides the login logic for the login client.
		/// </summary>
		/// <param name="Args">The command-line arguments passed to Black Lightning for use logging in.</param>
		/// <returns>An SalFile that can be used to login to a game and play.</returns>
		SalFile Login(string[] Args);
	}

	/// <summary>
	/// An attribute that tags Assemblies and defines which of its classes are Black Lightning Login Clients.
	/// </summary>
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple=true)]
	public class BLLoginClientAttribute : Attribute {
		// member data
		private Type _Type; // the type that is an ILoginClient

		/// <summary>
		/// Creates a new BLLoginClientAttribute.
		/// </summary>
		/// <param name="Type">A type that implements ILoginClient and wishes to be visible to Black Lightning.</param>
		public BLLoginClientAttribute(Type Type) {
			_Type = Type;
		}

		/// <summary>
		/// Gets or sets the type that implements ILoginClient and wishes to be visible to Black Lightning.
		/// </summary>
		public Type Type {
			get {
				return _Type;
			}
			set {
				_Type = value;
			}
		}
	}
	
	/// <summary>
	/// An attribute to be applied to ILoginClient-derived classes to give them a name other than their type.
	/// </summary>
	[AttributeUsage(AttributeTargets.Class)]
	public class LoginClientNameAttribute : Attribute {
		// member data
		private string _Name; // the name to apply to the ILoginClient

		/// <summary>
		/// Creates a new LoginClientNameAttribute.
		/// </summary>
		/// <param name="Name">The name to apply to the ILoginClient.</param>
		public LoginClientNameAttribute(string Name) {
			_Name = Name;
		}

		/// <summary>
		/// Gets or sets the name to apply to the ILoginClient.
		/// </summary>
		public string Name {
			get {
				return _Name;
			}
			set {
				_Name = value;
			}
		}
	}

	/// <summary>
	/// An enumeration of all the properties that an ILoginClient might have.
	/// </summary>
	public enum LoginClientProperty {
		/// <summary>
		/// (string) The text that should be displayed when the user requests help about the ILoginClient.
		/// </summary>
		HelpText,

		/// <summary>
		/// (string) The username that the user logged in with.  Stored by Black Lightning for use in @reconnect.
		/// </summary>
		Username,

		/// <summary>
		/// (string) The password that the user logged in with.  Stored by Black Lightning for use in @reconnect.
		/// </summary>
		Password,

		/// <summary>
		/// (string) The code of the game that the user logged into.  Stored by Black Lightning for use in @reconnect.
		/// </summary>
		GameCode,

		/// <summary>
		/// (string) The code of the character that the user logged in with.  Stored by Black Lightning for use in @reconnect.
		/// </summary>
		CharCode,

		/// <summary>
		/// (string) The code of the front end that the user selected ("STORM" or "WIZ").  Stored by Black Lightning for use in @reconnect.
		/// </summary>
		FECode
	}
}
